﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CApExportToRTRStatusObjectIssueDataContainer
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToRTR{

internal class CApExportToRTRStatusObjectIssueDataContainer
{
  internal CApExportToRTRStatusManager.Severity IssueSeverity { get; private set; }

  internal HashSet<CApExportToRTRStatusObjectIssueData> DatasOfIssue { get; private set; } = new HashSet<CApExportToRTRStatusObjectIssueData>();

  internal CApExportToRTRStatusObjectIssueDataContainer(
    CApExportToRTRStatusManager.Severity issueSeverity)
  {
    this.IssueSeverity = issueSeverity;
  }

  internal bool AddIssueForObjects(ITxObject mainObject, TxObjectList objects = null)
  {
    bool flag = true;
    if (!this.DatasOfIssue.Contains(new CApExportToRTRStatusObjectIssueData(mainObject)))
      this.DatasOfIssue.Add(new CApExportToRTRStatusObjectIssueData(mainObject, objects));
    else
      flag = false;
    return flag;
  }

  internal bool RemoveIssueForObject(ITxObject mainObject)
  {
    return this.DatasOfIssue.Remove(new CApExportToRTRStatusObjectIssueData(mainObject));
  }

  internal CApExportToRTRStatusObjectIssueData GetErrorForObject(ITxObject obj)
  {
    CApExportToRTRStatusObjectIssueData actualValue;
    this.DatasOfIssue.TryGetValue(new CApExportToRTRStatusObjectIssueData(obj), out actualValue);
    return actualValue;
  }

  internal void GenerateAllIssueLines(
    CApExportToRTRStatusManager.IssueType issueType,
    CApExportToRTRStatusIssueBuilder statusBuilder)
  {
    statusBuilder.Append(issueType, this);
  }

  internal void GenerateIssueLineForObject(
    CApExportToRTRStatusManager.IssueType issueType,
    CApExportToRTRStatusIssueBuilder statusBuilder,
    ITxObject obj)
  {
    if (!this.DatasOfIssue.Contains(new CApExportToRTRStatusObjectIssueData(obj)))
      return;
    statusBuilder.AppendTitle(issueType, this.IssueSeverity);
  }

  internal CApExportToRTRStatusManager.Severity ComputeSeverity()
  {
    return this.DatasOfIssue.Count <= 0 ? CApExportToRTRStatusManager.Severity.Ok : this.IssueSeverity;
  }

  internal CApExportToRTRStatusManager.Severity ComputeSeverityForObject(ITxObject obj)
  {
    return !this.DatasOfIssue.TryGetValue(new CApExportToRTRStatusObjectIssueData(obj), out CApExportToRTRStatusObjectIssueData _) ? CApExportToRTRStatusManager.Severity.Ok : this.IssueSeverity;
  }
}
